#ifndef _RETINANET_H_
#define _RETINANET_H_

#ifdef __cplusplus
extern "C" {
#endif


#include "hi_comm_svp.h"



#define RETINA_INPUT_SIZE (608)
#define RETINA_FPN_LAYER_NUM (5) // retinanet detect on 5 features, = pstDetParam->stModel.astSeg->u16DstNum
#define RETINA_LABEL_NUM (20) // retinanet label num
#define RETINA_PER_ANCHOR_NUM (9) // per anchor num
#define RETINA_LOC_NUM (4) // xyxy
#define RETINA_CLASS_THRESHOLD (0.0f) // (0.01f) // conf threshold
#define SHOW_CLASS_THRESHOLD (0.0f)
#define NMS_IOU_THRESHOLD (0.5f) // nms IoU threshold

#define SAVE_RESULT_NUM_MAX (76*76) // all result
#define DETECTION_RESULT_NUM_MAX (100) // final result

#define PRINT_FLAG (1) // 是否打印耗时信息


void RetinaNet(); // 运行函数

void Retinanet_HandleSig(); // 释放内存


 
typedef struct mySVP_SOFT_RETINA_S
{
	// ***************       NNIE blob infor       ***************
	HI_S32* detection_input_data[RETINA_FPN_LAYER_NUM]; // NNIE loc result
	HI_S32* softmax_input_data[RETINA_FPN_LAYER_NUM]; // NNIE conf result

	HI_U32 feature_width[RETINA_FPN_LAYER_NUM];
	HI_U32 feature_height[RETINA_FPN_LAYER_NUM];
	HI_U32 feature_stride[RETINA_FPN_LAYER_NUM];
	HI_U32 feature_channel_loc[RETINA_FPN_LAYER_NUM];
	HI_U32 feature_channel_conf[RETINA_FPN_LAYER_NUM];

	// ***************       anchor infor       ***************
	HI_S32 anchor_size[RETINA_FPN_LAYER_NUM]; // 32 64 128 256 512
	HI_S32 image_stride[RETINA_FPN_LAYER_NUM]; // 8 16 32 64 128
	HI_FLOAT anchor_rate[3]; // 0.5 1 2
	HI_FLOAT anchor_scale[3]; // 1 1.26 1.587

	// ***************       soft memory       ***************
	SVP_MEM_INFO_S ps32ResultMem; // to save [sroce class x y x y]
	HI_U32 total_detection_num; // how many bbox detected

	// SVP_MEM_INFO_S is_suppression; // to save suppression result

	SVP_MEM_INFO_S ps32FinalBbox; // to save [sroce class x y x y]
	HI_U32 final_detection_num; // how many bbox detected

	SVP_DST_BLOB_S stDstRoi; // 存储NNIE结果

	// ***************       file       ***************
	FILE *fp_result;

	// ----------------- 画框 -----------------
	SAMPLE_SVP_NNIE_RECT_ARRAY_S stRect; // 新加 参考rfcn例程，用于画框HDMI显示  最多30个类别
} SVP_SOFT_RETINA_S;


// 传递给线程的参数 JPG → NNIE → VO
typedef struct SVP_RETINA_THREAD
{
	VDEC_THREAD_PARAM_S *pstVdecSend; // VDEC信息
	SAMPLE_SVP_NNIE_PARAM_S *pstMobileSsdNnieParam; // NNIE信息
	SVP_SOFT_RETINA_S *pstMobileSsdSoftwareParam; // 软件解码信息
}myRETINA_THREAD;








#ifdef __cplusplus
}
#endif

#endif /* _RETINANET_H_ */
